package com.example.controller;


import com.example.entity.User;
import com.example.service.UserService;
import com.example.utils.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.websocket.server.PathParam;

@RestController
@RequestMapping("user")
public class UserController {

    @Autowired
    private UserService userService;


    @PostMapping("/register")
    public ResponseResult register(@RequestBody User user){
        return userService.register(user);
    }

    @GetMapping ("/userInfo")
    public ResponseResult userInfo(@PathParam("userId") String userId){
//        System.err.println("login---");
        return userService.userInfo(new Long(userId));
    }

    @PutMapping ("/userInfo")
    public ResponseResult updateInfo(@RequestBody User user){
        return userService.updateUserInfo(user);
    }

}
